package com.xtinno.controller;

import cn.com.apollo.platformbase.response.ResponseResult;
import com.xtinno.common.MDCUtils;
import com.xtinno.models.WorkFlowRequestModel;
import com.xtinno.service.WorkFlowFactory;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 要素推理
 *
 * @author GuanLei
 * @time 2025/5/21 19:34
 */
@Tag(name = "工作流")
@RestController
@RequestMapping("/v1/workflow")
@RequiredArgsConstructor
@Slf4j
public class WorkFlowController {
    private final WorkFlowFactory workFlowFactory;
    private final HttpServletRequest request; //自动注入request

    /**
     * 要素推理
     */
    @PostMapping(value = "/run")
    public ResponseResult<Object> elementReasoning(@RequestBody WorkFlowRequestModel workFlowInputsModel) {
        var obj = workFlowFactory.getWorkFlowMap(workFlowInputsModel.getWorkflowId()).RunWorkFlow(workFlowInputsModel);
        return ResponseResult.ok(obj);
    }
}
